package com.tpsix.datascope;

import com.tpsix.controller.vm.RoleVM;
import com.tpsix.domain.SysUser;
import com.tpsix.enums.DataScopeTypeEnum;
import com.tpsix.service.SysUserService;
import com.tpsix.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * 本级
 */
@Component
@AllArgsConstructor
public class ThisLevelDataScopeHandler implements DataScopeHandler {

    private final SysUserService sysUserService;

    @Override
    public List<Integer> getDeptIds(RoleVM roleVM, DataScopeTypeEnum dataScopeTypeEnum) {
        SysUser sysUser = sysUserService.findUserDetailsById(SecurityUtils.getUserId());
        return Collections.singletonList(sysUser.getDeptId());
    }

}
